<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>GrPPI: parallel_execution_native.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.svg"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">GrPPI
   &#160;<span id="projectnumber">0.2</span>
   </div>
   <div id="projectbrief">Generic and Reusable Parallel Pattern Interface</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_b519bdaee6a7f8dbbe55c1237cf8f544.html">native</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">parallel_execution_native.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="parallel__execution__native_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="preprocessor">#ifndef GRPPI_NATIVE_PARALLEL_EXECUTION_NATIVE_H</span></div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="preprocessor">#define GRPPI_NATIVE_PARALLEL_EXECUTION_NATIVE_H</span></div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;</div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="preprocessor">#include &quot;../common/mpmc_queue.h&quot;</span></div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="pool_8h.html">pool.h</a>&quot;</span></div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="preprocessor">#include &lt;thread&gt;</span></div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="preprocessor">#include &lt;atomic&gt;</span></div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="preprocessor">#include &lt;algorithm&gt;</span></div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;<span class="preprocessor">#include &lt;vector&gt;</span></div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="preprocessor">#include &lt;type_traits&gt;</span></div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;</div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacegrppi.html">grppi</a> {</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;</div><div class="line"><a name="l00049"></a><span class="lineno"><a class="line" href="classgrppi_1_1thread__registry.html">   49</a></span>&#160;<span class="keyword">class </span><a class="code" href="classgrppi_1_1thread__registry.html">thread_registry</a> {</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;  <a class="code" href="classgrppi_1_1thread__registry.html#a3a6b9476b404f594df2d540dd2fad4b2">thread_registry</a>() noexcept = <span class="keywordflow">default</span>;</div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classgrppi_1_1thread__registry.html#a3c61f318e381df30a3d1bcd5a5f83f69">register_thread</a>() noexcept;</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classgrppi_1_1thread__registry.html#a6998752c4b6f918c36e808a8a8d60112">deregister_thread</a>() noexcept;</div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;</div><div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;  <span class="keywordtype">int</span> <a class="code" href="classgrppi_1_1thread__registry.html#a4fe2639e9ddc939d6ecfa9d2db99dfee">current_index</a>() <span class="keyword">const</span> noexcept;</div><div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;</div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;<span class="keyword">private</span>:</div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;  <span class="keyword">mutable</span> std::atomic_flag lock_ = ATOMIC_FLAG_INIT;</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;  std::vector&lt;std::thread::id&gt; ids_;</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;};</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;</div><div class="line"><a name="l00075"></a><span class="lineno"><a class="line" href="classgrppi_1_1thread__registry.html#a3c61f318e381df30a3d1bcd5a5f83f69">   75</a></span>&#160;<span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classgrppi_1_1thread__registry.html#a3c61f318e381df30a3d1bcd5a5f83f69">thread_registry::register_thread</a>() noexcept </div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;{</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;  <span class="keyword">using namespace </span><a class="code" href="namespacestd.html">std</a>;</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;  <span class="keywordflow">while</span> (lock_.test_and_set(memory_order_acquire)) {}</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;  <span class="keyword">auto</span> this_id = this_thread::get_id();</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;  ids_.push_back(this_id);</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;  lock_.clear(memory_order_release);</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;}</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;</div><div class="line"><a name="l00084"></a><span class="lineno"><a class="line" href="classgrppi_1_1thread__registry.html#a6998752c4b6f918c36e808a8a8d60112">   84</a></span>&#160;<span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classgrppi_1_1thread__registry.html#a6998752c4b6f918c36e808a8a8d60112">thread_registry::deregister_thread</a>() noexcept</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;{</div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;  <span class="keyword">using namespace </span><a class="code" href="namespacestd.html">std</a>;</div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;  <span class="keywordflow">while</span> (lock_.test_and_set(memory_order_acquire)) {}</div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;  <span class="keyword">auto</span> this_id = this_thread::get_id();</div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;  <span class="keyword">auto</span> current = find(begin(ids_), end(ids_), this_id);</div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;  *current = {}; <span class="comment">//Empty thread</span></div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;  lock_.clear(memory_order_release);</div><div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;}</div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;</div><div class="line"><a name="l00094"></a><span class="lineno"><a class="line" href="classgrppi_1_1thread__registry.html#a4fe2639e9ddc939d6ecfa9d2db99dfee">   94</a></span>&#160;<span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="classgrppi_1_1thread__registry.html#a4fe2639e9ddc939d6ecfa9d2db99dfee">thread_registry::current_index</a>() const noexcept</div><div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;{</div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;  <span class="keyword">using namespace </span><a class="code" href="namespacestd.html">std</a>;</div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;  <span class="keywordflow">while</span> (lock_.test_and_set(memory_order_acquire)) {}</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;  <span class="keyword">auto</span> this_id = this_thread::get_id();</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;  <span class="keyword">auto</span> current = find(begin(ids_), end(ids_), this_id);</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;  <span class="keyword">auto</span> index = distance(begin(ids_), current);</div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;  lock_.clear(memory_order_release);</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;  <span class="keywordflow">return</span> index;</div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;};</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;</div><div class="line"><a name="l00111"></a><span class="lineno"><a class="line" href="classgrppi_1_1native__thread__manager.html">  111</a></span>&#160;<span class="keyword">class </span><a class="code" href="classgrppi_1_1native__thread__manager.html">native_thread_manager</a> {</div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00116"></a><span class="lineno"><a class="line" href="classgrppi_1_1native__thread__manager.html#a7f02489612c3bec56c829b3336c50fbe">  116</a></span>&#160;  <a class="code" href="classgrppi_1_1native__thread__manager.html#a7f02489612c3bec56c829b3336c50fbe">native_thread_manager</a>(<a class="code" href="classgrppi_1_1thread__registry.html">thread_registry</a> &amp; registry) </div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;      : registry_{registry}</div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;  { registry_.<a class="code" href="classgrppi_1_1thread__registry.html#a3c61f318e381df30a3d1bcd5a5f83f69">register_thread</a>(); }</div><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;</div><div class="line"><a name="l00123"></a><span class="lineno"><a class="line" href="classgrppi_1_1native__thread__manager.html#a02e32d5528da8067d367e1596d690741">  123</a></span>&#160;  <a class="code" href="classgrppi_1_1native__thread__manager.html#a02e32d5528da8067d367e1596d690741">~native_thread_manager</a>() { </div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;    registry_.deregister_thread(); </div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;  }</div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;<span class="keyword">private</span>:</div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;  <a class="code" href="classgrppi_1_1thread__registry.html">thread_registry</a> &amp; registry_;</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;};</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;</div><div class="line"><a name="l00136"></a><span class="lineno"><a class="line" href="classgrppi_1_1parallel__execution__native.html">  136</a></span>&#160;<span class="keyword">class </span><a class="code" href="classgrppi_1_1parallel__execution__native.html">parallel_execution_native</a> {</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;</div><div class="line"><a name="l00149"></a><span class="lineno"><a class="line" href="classgrppi_1_1parallel__execution__native.html#ade8219a47138ed32dd2209097c6edb91">  149</a></span>&#160;  <a class="code" href="classgrppi_1_1parallel__execution__native.html#ade8219a47138ed32dd2209097c6edb91">parallel_execution_native</a>() noexcept :</div><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;      <a class="code" href="classgrppi_1_1parallel__execution__native.html">parallel_execution_native</a>{</div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;          <span class="keyword">static_cast&lt;</span><span class="keywordtype">int</span><span class="keyword">&gt;</span>(2 * std::thread::hardware_concurrency()), </div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;          <span class="keyword">true</span>}</div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;  {}</div><div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;</div><div class="line"><a name="l00163"></a><span class="lineno"><a class="line" href="classgrppi_1_1parallel__execution__native.html#a2b98f877a6e1273329b77e80f8c70d05">  163</a></span>&#160;  <a class="code" href="classgrppi_1_1parallel__execution__native.html#a2b98f877a6e1273329b77e80f8c70d05">parallel_execution_native</a>(<span class="keywordtype">int</span> concurrency_degree, <span class="keywordtype">bool</span> ordering=<span class="keyword">true</span>) noexcept :</div><div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;    concurrency_degree_{concurrency_degree},</div><div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;    ordering_{ordering}</div><div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;  {</div><div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;    pool.initialise(concurrency_degree_);</div><div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;  }</div><div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;</div><div class="line"><a name="l00173"></a><span class="lineno"><a class="line" href="classgrppi_1_1parallel__execution__native.html#a19ab3a76eaf5ff20e005e4c231de5668">  173</a></span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classgrppi_1_1parallel__execution__native.html#a19ab3a76eaf5ff20e005e4c231de5668">set_concurrency_degree</a>(<span class="keywordtype">int</span> degree) noexcept { concurrency_degree_ = degree; }</div><div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;</div><div class="line"><a name="l00178"></a><span class="lineno"><a class="line" href="classgrppi_1_1parallel__execution__native.html#aae3c5760c422c19a391ce1ddaa5e9f0b">  178</a></span>&#160;  <span class="keywordtype">int</span> <a class="code" href="classgrppi_1_1parallel__execution__native.html#aae3c5760c422c19a391ce1ddaa5e9f0b">concurrency_degree</a>() const noexcept { <span class="keywordflow">return</span> concurrency_degree_; }</div><div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;</div><div class="line"><a name="l00183"></a><span class="lineno"><a class="line" href="classgrppi_1_1parallel__execution__native.html#ac71cfba0f7349d3ccfa4ffd0133a7298">  183</a></span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classgrppi_1_1parallel__execution__native.html#ac71cfba0f7349d3ccfa4ffd0133a7298">enable_ordering</a>() noexcept { ordering_=<span class="keyword">true</span>; }</div><div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;</div><div class="line"><a name="l00188"></a><span class="lineno"><a class="line" href="classgrppi_1_1parallel__execution__native.html#a5d64864ad9a1712b2528c0d424fd7ae4">  188</a></span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classgrppi_1_1parallel__execution__native.html#a5d64864ad9a1712b2528c0d424fd7ae4">disable_ordering</a>() noexcept { ordering_=<span class="keyword">false</span>; }</div><div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;</div><div class="line"><a name="l00193"></a><span class="lineno"><a class="line" href="classgrppi_1_1parallel__execution__native.html#a865f895d5f3e10b6f0cfa55f197c109b">  193</a></span>&#160;  <span class="keywordtype">bool</span> <a class="code" href="classgrppi_1_1parallel__execution__native.html#a865f895d5f3e10b6f0cfa55f197c109b">is_ordered</a>() const noexcept { <span class="keywordflow">return</span> ordering_; }</div><div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;</div><div class="line"><a name="l00199"></a><span class="lineno"><a class="line" href="classgrppi_1_1parallel__execution__native.html#aa3fb66a10cab14001a371be7b351c745">  199</a></span>&#160;  <a class="code" href="classgrppi_1_1native__thread__manager.html">native_thread_manager</a> <a class="code" href="classgrppi_1_1parallel__execution__native.html#aa3fb66a10cab14001a371be7b351c745">thread_manager</a>() { </div><div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="classgrppi_1_1native__thread__manager.html">native_thread_manager</a>{thread_registry_}; </div><div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;  }</div><div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;</div><div class="line"><a name="l00207"></a><span class="lineno"><a class="line" href="classgrppi_1_1parallel__execution__native.html#a969c78379311aa8678df7eaac0ae33b6">  207</a></span>&#160;  <span class="keywordtype">int</span> <a class="code" href="classgrppi_1_1parallel__execution__native.html#a969c78379311aa8678df7eaac0ae33b6">get_thread_id</a>() const noexcept {</div><div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;    <span class="keywordflow">return</span> thread_registry_.current_index();</div><div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;  }</div><div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;  </div><div class="line"><a name="l00214"></a><span class="lineno"><a class="line" href="classgrppi_1_1parallel__execution__native.html#a2d8ff67ca30e0fa19ad0c9365a59ff02">  214</a></span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classgrppi_1_1parallel__execution__native.html#a2d8ff67ca30e0fa19ad0c9365a59ff02">set_queue_attributes</a>(<span class="keywordtype">int</span> size, <a class="code" href="namespacegrppi.html#aa0514650a765d4853343655e7588662b">queue_mode</a> mode) noexcept {</div><div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;    queue_size_ = size;</div><div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;    queue_mode_ = mode;</div><div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;  }</div><div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;</div><div class="line"><a name="l00224"></a><span class="lineno">  224</span>&#160;  <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div><div class="line"><a name="l00225"></a><span class="lineno"><a class="line" href="classgrppi_1_1parallel__execution__native.html#a5c310952de159f2b4d62bdae4b360d8f">  225</a></span>&#160;  <a class="code" href="classgrppi_1_1mpmc__queue.html">mpmc_queue&lt;T&gt;</a> <a class="code" href="classgrppi_1_1parallel__execution__native.html#a5c310952de159f2b4d62bdae4b360d8f">make_queue</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;    <span class="keywordflow">return</span> {queue_size_, queue_mode_};</div><div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;  }</div><div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;</div><div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;<span class="keyword">public</span>: </div><div class="line"><a name="l00235"></a><span class="lineno"><a class="line" href="classgrppi_1_1parallel__execution__native.html#ac20c4179a163163d48176c7f81866594">  235</a></span>&#160;  <a class="code" href="classgrppi_1_1thread__pool.html">thread_pool</a> <a class="code" href="classgrppi_1_1parallel__execution__native.html#ac20c4179a163163d48176c7f81866594">pool</a>;</div><div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160;</div><div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;<span class="keyword">private</span>: </div><div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;  <a class="code" href="classgrppi_1_1thread__registry.html">thread_registry</a> thread_registry_;</div><div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160;</div><div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;  <span class="keywordtype">int</span> concurrency_degree_;</div><div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;  <span class="keywordtype">bool</span> ordering_;</div><div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;</div><div class="line"><a name="l00243"></a><span class="lineno">  243</span>&#160;  constexpr <span class="keyword">static</span> <span class="keywordtype">int</span> default_queue_size = 100;</div><div class="line"><a name="l00244"></a><span class="lineno">  244</span>&#160;  <span class="keywordtype">int</span> queue_size_ = default_queue_size;</div><div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160;</div><div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160;  <a class="code" href="namespacegrppi.html#aa0514650a765d4853343655e7588662b">queue_mode</a> queue_mode_ = <a class="code" href="namespacegrppi.html#aa0514650a765d4853343655e7588662ba14343966a1d7dce7526e57cf2206d19d">queue_mode::blocking</a>;</div><div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;};</div><div class="line"><a name="l00248"></a><span class="lineno">  248</span>&#160;</div><div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> E&gt;</div><div class="line"><a name="l00254"></a><span class="lineno"><a class="line" href="namespacegrppi.html#a42fb74f9dece6623d7f01995d4adc5fe">  254</a></span>&#160;constexpr <span class="keywordtype">bool</span> <a class="code" href="namespacegrppi.html#a42fb74f9dece6623d7f01995d4adc5fe">is_parallel_execution_native</a>() {</div><div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;  <span class="keywordflow">return</span> std::is_same&lt;E, parallel_execution_native&gt;::value;</div><div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;}</div><div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160;</div><div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> E&gt;</div><div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;constexpr <span class="keywordtype">bool</span> <a class="code" href="namespacegrppi.html#a06dcb52b246f0cee715a28b123eeb1de">is_supported</a>();</div><div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;</div><div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160;<span class="keyword">template</span> &lt;&gt;</div><div class="line"><a name="l00269"></a><span class="lineno"><a class="line" href="namespacegrppi.html#ac0641c069b2aebeee3b0ac9ddd6c97ea">  269</a></span>&#160;constexpr <span class="keywordtype">bool</span> <a class="code" href="namespacegrppi.html#ac0641c069b2aebeee3b0ac9ddd6c97ea">is_supported&lt;parallel_execution_native&gt;</a>() {</div><div class="line"><a name="l00270"></a><span class="lineno">  270</span>&#160;  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div><div class="line"><a name="l00271"></a><span class="lineno">  271</span>&#160;}</div><div class="line"><a name="l00272"></a><span class="lineno">  272</span>&#160;</div><div class="line"><a name="l00273"></a><span class="lineno">  273</span>&#160;</div><div class="line"><a name="l00274"></a><span class="lineno">  274</span>&#160;} <span class="comment">// end namespace grppi</span></div><div class="line"><a name="l00275"></a><span class="lineno">  275</span>&#160;</div><div class="line"><a name="l00276"></a><span class="lineno">  276</span>&#160;</div><div class="line"><a name="l00277"></a><span class="lineno">  277</span>&#160;<span class="preprocessor">#endif</span></div><div class="ttc" id="namespacegrppi_html"><div class="ttname"><a href="namespacegrppi.html">grppi</a></div><div class="ttdef"><b>Definition:</b> callable_traits.h:24</div></div>
<div class="ttc" id="classgrppi_1_1parallel__execution__native_html_a19ab3a76eaf5ff20e005e4c231de5668"><div class="ttname"><a href="classgrppi_1_1parallel__execution__native.html#a19ab3a76eaf5ff20e005e4c231de5668">grppi::parallel_execution_native::set_concurrency_degree</a></div><div class="ttdeci">void set_concurrency_degree(int degree) noexcept</div><div class="ttdoc">Set number of grppi threads. </div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:173</div></div>
<div class="ttc" id="namespacegrppi_html_ac0641c069b2aebeee3b0ac9ddd6c97ea"><div class="ttname"><a href="namespacegrppi.html#ac0641c069b2aebeee3b0ac9ddd6c97ea">grppi::is_supported&lt; parallel_execution_native &gt;</a></div><div class="ttdeci">constexpr bool is_supported&lt; parallel_execution_native &gt;()</div><div class="ttdoc">Specialization stating that parallel_execution_native is supported. </div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:269</div></div>
<div class="ttc" id="classgrppi_1_1native__thread__manager_html_a7f02489612c3bec56c829b3336c50fbe"><div class="ttname"><a href="classgrppi_1_1native__thread__manager.html#a7f02489612c3bec56c829b3336c50fbe">grppi::native_thread_manager::native_thread_manager</a></div><div class="ttdeci">native_thread_manager(thread_registry &amp;registry)</div><div class="ttdoc">Saves a reference to the registry and registers current thread. </div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:116</div></div>
<div class="ttc" id="pool_8h_html"><div class="ttname"><a href="pool_8h.html">pool.h</a></div></div>
<div class="ttc" id="namespacegrppi_html_a06dcb52b246f0cee715a28b123eeb1de"><div class="ttname"><a href="namespacegrppi.html#a06dcb52b246f0cee715a28b123eeb1de">grppi::is_supported</a></div><div class="ttdeci">constexpr bool is_supported()</div><div class="ttdoc">Metafunction that determines if type E is supported in the current build. </div></div>
<div class="ttc" id="classgrppi_1_1parallel__execution__native_html_ac71cfba0f7349d3ccfa4ffd0133a7298"><div class="ttname"><a href="classgrppi_1_1parallel__execution__native.html#ac71cfba0f7349d3ccfa4ffd0133a7298">grppi::parallel_execution_native::enable_ordering</a></div><div class="ttdeci">void enable_ordering() noexcept</div><div class="ttdoc">Enable ordering. </div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:183</div></div>
<div class="ttc" id="classgrppi_1_1parallel__execution__native_html_aae3c5760c422c19a391ce1ddaa5e9f0b"><div class="ttname"><a href="classgrppi_1_1parallel__execution__native.html#aae3c5760c422c19a391ce1ddaa5e9f0b">grppi::parallel_execution_native::concurrency_degree</a></div><div class="ttdeci">int concurrency_degree() const noexcept</div><div class="ttdoc">Get number of grppi trheads. </div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:178</div></div>
<div class="ttc" id="classgrppi_1_1parallel__execution__native_html_a2d8ff67ca30e0fa19ad0c9365a59ff02"><div class="ttname"><a href="classgrppi_1_1parallel__execution__native.html#a2d8ff67ca30e0fa19ad0c9365a59ff02">grppi::parallel_execution_native::set_queue_attributes</a></div><div class="ttdeci">void set_queue_attributes(int size, queue_mode mode) noexcept</div><div class="ttdoc">Sets the attributes for the queues built through make_queue&lt;T&gt;() </div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:214</div></div>
<div class="ttc" id="namespacestd_html"><div class="ttname"><a href="namespacestd.html">std</a></div><div class="ttdoc">STL namespace. </div></div>
<div class="ttc" id="classgrppi_1_1parallel__execution__native_html_ac20c4179a163163d48176c7f81866594"><div class="ttname"><a href="classgrppi_1_1parallel__execution__native.html#ac20c4179a163163d48176c7f81866594">grppi::parallel_execution_native::pool</a></div><div class="ttdeci">thread_pool pool</div><div class="ttdoc">Thread pool for lanching workers. </div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:235</div></div>
<div class="ttc" id="namespacegrppi_html_aa0514650a765d4853343655e7588662b"><div class="ttname"><a href="namespacegrppi.html#aa0514650a765d4853343655e7588662b">grppi::queue_mode</a></div><div class="ttdeci">queue_mode</div><div class="ttdef"><b>Definition:</b> mpmc_queue.h:35</div></div>
<div class="ttc" id="classgrppi_1_1thread__registry_html_a6998752c4b6f918c36e808a8a8d60112"><div class="ttname"><a href="classgrppi_1_1thread__registry.html#a6998752c4b6f918c36e808a8a8d60112">grppi::thread_registry::deregister_thread</a></div><div class="ttdeci">void deregister_thread() noexcept</div><div class="ttdoc">Removes current thread id from the registry. </div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:84</div></div>
<div class="ttc" id="classgrppi_1_1parallel__execution__native_html"><div class="ttname"><a href="classgrppi_1_1parallel__execution__native.html">grppi::parallel_execution_native</a></div><div class="ttdoc">Native parallel execution policy. This policy uses ISO C++ threads as implementation building block a...</div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:136</div></div>
<div class="ttc" id="classgrppi_1_1thread__registry_html_a3a6b9476b404f594df2d540dd2fad4b2"><div class="ttname"><a href="classgrppi_1_1thread__registry.html#a3a6b9476b404f594df2d540dd2fad4b2">grppi::thread_registry::thread_registry</a></div><div class="ttdeci">thread_registry() noexcept=default</div></div>
<div class="ttc" id="classgrppi_1_1mpmc__queue_html"><div class="ttname"><a href="classgrppi_1_1mpmc__queue.html">grppi::mpmc_queue</a></div><div class="ttdef"><b>Definition:</b> mpmc_queue.h:38</div></div>
<div class="ttc" id="classgrppi_1_1parallel__execution__native_html_ade8219a47138ed32dd2209097c6edb91"><div class="ttname"><a href="classgrppi_1_1parallel__execution__native.html#ade8219a47138ed32dd2209097c6edb91">grppi::parallel_execution_native::parallel_execution_native</a></div><div class="ttdeci">parallel_execution_native() noexcept</div><div class="ttdoc">Default construct a native parallel execution policy. </div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:149</div></div>
<div class="ttc" id="namespacegrppi_html_aa0514650a765d4853343655e7588662ba14343966a1d7dce7526e57cf2206d19d"><div class="ttname"><a href="namespacegrppi.html#aa0514650a765d4853343655e7588662ba14343966a1d7dce7526e57cf2206d19d">grppi::queue_mode::blocking</a></div></div>
<div class="ttc" id="classgrppi_1_1native__thread__manager_html_a02e32d5528da8067d367e1596d690741"><div class="ttname"><a href="classgrppi_1_1native__thread__manager.html#a02e32d5528da8067d367e1596d690741">grppi::native_thread_manager::~native_thread_manager</a></div><div class="ttdeci">~native_thread_manager()</div><div class="ttdoc">Deregisters current thread from the registry. </div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:123</div></div>
<div class="ttc" id="namespacegrppi_html_a42fb74f9dece6623d7f01995d4adc5fe"><div class="ttname"><a href="namespacegrppi.html#a42fb74f9dece6623d7f01995d4adc5fe">grppi::is_parallel_execution_native</a></div><div class="ttdeci">constexpr bool is_parallel_execution_native()</div><div class="ttdoc">Metafunction that determines if type E is parallel_execution_native. </div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:254</div></div>
<div class="ttc" id="classgrppi_1_1thread__registry_html_a3c61f318e381df30a3d1bcd5a5f83f69"><div class="ttname"><a href="classgrppi_1_1thread__registry.html#a3c61f318e381df30a3d1bcd5a5f83f69">grppi::thread_registry::register_thread</a></div><div class="ttdeci">void register_thread() noexcept</div><div class="ttdoc">Adds the current thread id in the registry. </div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:75</div></div>
<div class="ttc" id="classgrppi_1_1parallel__execution__native_html_aa3fb66a10cab14001a371be7b351c745"><div class="ttname"><a href="classgrppi_1_1parallel__execution__native.html#aa3fb66a10cab14001a371be7b351c745">grppi::parallel_execution_native::thread_manager</a></div><div class="ttdeci">native_thread_manager thread_manager()</div><div class="ttdoc">Get a manager object for registration/deregistration in the thread index table for current thread...</div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:199</div></div>
<div class="ttc" id="classgrppi_1_1thread__registry_html_a4fe2639e9ddc939d6ecfa9d2db99dfee"><div class="ttname"><a href="classgrppi_1_1thread__registry.html#a4fe2639e9ddc939d6ecfa9d2db99dfee">grppi::thread_registry::current_index</a></div><div class="ttdeci">int current_index() const noexcept</div><div class="ttdoc">Integer index for current thread. </div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:94</div></div>
<div class="ttc" id="classgrppi_1_1parallel__execution__native_html_a2b98f877a6e1273329b77e80f8c70d05"><div class="ttname"><a href="classgrppi_1_1parallel__execution__native.html#a2b98f877a6e1273329b77e80f8c70d05">grppi::parallel_execution_native::parallel_execution_native</a></div><div class="ttdeci">parallel_execution_native(int concurrency_degree, bool ordering=true) noexcept</div><div class="ttdoc">Constructs a native parallel execution policy. </div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:163</div></div>
<div class="ttc" id="classgrppi_1_1thread__registry_html"><div class="ttname"><a href="classgrppi_1_1thread__registry.html">grppi::thread_registry</a></div><div class="ttdoc">Thread index table to provide portable natural thread indices. </div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:49</div></div>
<div class="ttc" id="classgrppi_1_1parallel__execution__native_html_a5d64864ad9a1712b2528c0d424fd7ae4"><div class="ttname"><a href="classgrppi_1_1parallel__execution__native.html#a5d64864ad9a1712b2528c0d424fd7ae4">grppi::parallel_execution_native::disable_ordering</a></div><div class="ttdeci">void disable_ordering() noexcept</div><div class="ttdoc">Disable ordering. </div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:188</div></div>
<div class="ttc" id="classgrppi_1_1native__thread__manager_html"><div class="ttname"><a href="classgrppi_1_1native__thread__manager.html">grppi::native_thread_manager</a></div><div class="ttdoc">RAII class to manage registration/deregistration pairs. This class allows to manage automatic deregis...</div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:111</div></div>
<div class="ttc" id="classgrppi_1_1thread__pool_html"><div class="ttname"><a href="classgrppi_1_1thread__pool.html">grppi::thread_pool</a></div><div class="ttdef"><b>Definition:</b> pool.h:30</div></div>
<div class="ttc" id="classgrppi_1_1parallel__execution__native_html_a5c310952de159f2b4d62bdae4b360d8f"><div class="ttname"><a href="classgrppi_1_1parallel__execution__native.html#a5c310952de159f2b4d62bdae4b360d8f">grppi::parallel_execution_native::make_queue</a></div><div class="ttdeci">mpmc_queue&lt; T &gt; make_queue() const </div><div class="ttdoc">Makes a communication queue for elements of type T. Constructs a queue using the attributes that can ...</div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:225</div></div>
<div class="ttc" id="classgrppi_1_1parallel__execution__native_html_a969c78379311aa8678df7eaac0ae33b6"><div class="ttname"><a href="classgrppi_1_1parallel__execution__native.html#a969c78379311aa8678df7eaac0ae33b6">grppi::parallel_execution_native::get_thread_id</a></div><div class="ttdeci">int get_thread_id() const noexcept</div><div class="ttdoc">Get index of current thread in the thread table. </div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:207</div></div>
<div class="ttc" id="classgrppi_1_1parallel__execution__native_html_a865f895d5f3e10b6f0cfa55f197c109b"><div class="ttname"><a href="classgrppi_1_1parallel__execution__native.html#a865f895d5f3e10b6f0cfa55f197c109b">grppi::parallel_execution_native::is_ordered</a></div><div class="ttdeci">bool is_ordered() const noexcept</div><div class="ttdoc">Is execution ordered. </div><div class="ttdef"><b>Definition:</b> parallel_execution_native.h:193</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>
